package com.chebaohui.iqs.entity;

import com.chebaohui.iqs.config.ResultCode;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel(value = "Result", description = "接口返回父类")
public class Result<T> {

	@ApiModelProperty(value = "接口状态")
	private boolean state;

	@ApiModelProperty(value = "状态编码")
	private String code;

	@ApiModelProperty(value = "接口状态信息描述")
	private String msg;

	@ApiModelProperty(value = "返回结果集")
	private T data;

	public Result() {
		super();
	}

	public Result(ResultCode res) {
		super();
		this.state = res.isState();
		this.code = res.getCode();
		this.msg = res.getMsg();
	}
	
	public Result(ResultCode res,String msg) {
		super();
		this.state = res.isState();
		this.code = res.getCode();
		this.msg = res.getMsg()+msg;
	}

	public Result(ResultCode res, T t) {
		super();
		this.state = res.isState();
		this.code = res.getCode();
		this.msg = res.getMsg();
		this.data = t;
	}

	public boolean isState() {
		return state;
	}

	public void setState(boolean state) {
		this.state = state;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

	@Override
	public String toString() {
		return "Result {state=" + state + ", code=" + code + ", msg=" + msg + ", data=" + data.toString() + " }";
	}

}
